<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var arr=[1,2,3]
var sum =arr.reduce(function(s,item,index){
    //item;数组元素
    //index；索引号
    return s+item
},0)
console.log(sum)//6,计算数组的总和
    </script>
</body>
</html>